home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 337 < prev    next >
Text File  |  1996-08-06  |  1KB  |  28 lines

  1. Newsgroups: comp.lang.c,comp.std.c,comp.lang.c++
  2. Path: blackbush.xlink.net!slsv6bt!news
  3. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  4. Subject: Re: Floating Point arithmetic problem
  5. In-Reply-To: harmon@pegasus.montclair.edu's message of 15 Feb 1996 02:05:35 -0500
  6. Message-ID: <KANZE.96Feb20112957@slsvewt.lts.sel.alcatel.de>
  7. Sender: news@lts.sel.alcatel.de
  8. Organization: GABI Software, Sarl.
  9. References: <c968da6jzm.fsf@damayanti.india.ti.com>
  10.     <harmon.824366374@pegasus.montclair.edu>
  11. Date: 20 Feb 1996 10:29:57 GMT
  12.  
  13. In article <harmon.824366374@pegasus.montclair.edu>
  14. harmon@pegasus.montclair.edu (Derek Harmon) writes:
  15.  
  16.     [To effectively round to n digits precision...]
  17. |>    When epsilon is a power of 10, say 0.0001, for positive n you could try
  18. |> epsilon * floor( d * (1.0 / epsilon));  and that might be all you need.
  19.  
  20. I'd probably try `epsilon * floor( d * (1.0 / epsilon) + 0.5)'.  Otherwise,
  21. values like 2.322199999... will become 2.3221, instead of 2.3222.
  22. -- 
  23. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  24. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  25. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  26.                 -- A la recherche d'une activitΘ dans une region francophone
  27.  
  28.